package com.gxa.p2p.controller;

import com.gxa.p2p.common.JsonResult;
import com.gxa.p2p.pojo.Markclass;
import com.gxa.p2p.service.MarkTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.swing.*;
import java.util.List;
import java.util.Map;

/**
 * @author Bei
 * @date 2021/10/25 23:59
 */

@CrossOrigin
@RestController
@RequestMapping("/markType")
@Api(value = "标的分类的接口")
public class MarkTypeController {

    @Autowired
    MarkTypeService markTypeService = null;
    /**
     * 接口19
     * 廖泓宇
     */
    @RequestMapping(value = "/findAll",method = RequestMethod.POST)
    @ApiOperation("借款标类别全查")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "page", required = false, dataType = "int"),
            @ApiImplicitParam(name = "size", value = "size", required = false, dataType = "int"),
    })
    public Map findAll(@RequestParam("page") Integer page,@RequestParam("size") Integer size){
        List<Markclass> all = markTypeService.findAll(page,size);
        Integer all1 = markTypeService.findAll();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.put("count",all1);
        jsonResult.setData(all);
        return jsonResult.getDataMap();
    }

    /**
     * 接口20
     * 廖泓宇
     */
    @RequestMapping(value = "/addMarkType",method = RequestMethod.POST)
    @ApiOperation("增加分类")
    public Map addMarkType(@RequestBody Markclass markclass){
        markTypeService.addMarkType(markclass);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        return jsonResult.getDataMap();
    }

    /**
     * 接口21
     * 廖泓宇
     */
    @RequestMapping(value = "/updateMarkType",method = RequestMethod.POST)
    @ApiOperation("修改分类信息")
    public Map updateMarkType(@RequestBody Markclass markclass){
        markTypeService.updateMarkType(markclass);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        return jsonResult.getDataMap();
    }

}
